<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/19
 * Time: 18:09
 */

namespace Game\Library;


use Game\Config\Config;
use Predis\Client;

class Redis
{
    /** @var Array  */
    private static $instance;

    public static function getInstance($redisDB = Config::Redis_Database) : Client
    {
        if(!isset(self::$instance[$redisDB])){
            $redis = new Client(Config::Redis_HostPort);
            if(Config::Redis_Password){
                $redis->auth(Config::Redis_Password);
            }
            $redis->select($redisDB);
            self::$instance[$redisDB] = $redis;
        }
        return self::$instance[$redisDB];
    }
}